package com.example.yangxueqin

import android.os.Bundle
import android.widget.ArrayAdapter
import android.widget.ListView
import androidx.appcompat.app.AppCompatActivity
import java.io.File

class HistoryActivity : AppCompatActivity() {

    private lateinit var listView: ListView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_history)

        listView = findViewById(R.id.listView)
        loadHistory()
    }

    private fun loadHistory() {
        val file = File(filesDir, "history.txt")
        if (file.exists()) {
            val content = file.readText()
            val numbers = content.split(",").map { it.toInt() }
            val adapter = ArrayAdapter(this, R.layout.list_item, numbers)
            listView.adapter = adapter
        }
    }
}